#include<stdio.h>
int check(int year)
{
    if(year%100!=0)
    {
        if(year%4==0)
        {
            return 29;
        }
        else
        {
            return 28;
        }
    }
    else
    {
        if(year%400==0)
        {
            return 29;
        }
        else
        {
            return 28;
        }
    }
}
int main()
{
    int year,month,day,total = 0;  // 初始化total为0
    scanf("%d %d %d",&year,&month,&day);
    int arr[12]={31,check(year),31,30,31,30,31,31,30,31,30,31};
    for(int i=0;i<month-1;i++)
    {
        total+=arr[i];
    }
    total+=day;
    printf("%d",total);
    return 0;
}